package cn.yunhe.servlet.FboardSboard;

import cn.yunhe.entity.Sboard;
import cn.yunhe.service.FboardService;
import cn.yunhe.service.SboardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/productSecondClass2DeleteServlet")
public class productSecondClass2DeleteServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //s1:参数接收
        String sbid2Str=request.getParameter("sbid");
        System.out.println("<===sbid2Str====>"+sbid2Str);
        int sbid=Integer.parseInt(sbid2Str);
        //s2:
        SboardService sboardService=new SboardService();
        //s3:删除指定的二级版块
        Sboard sboard=sboardService.searchSboardBySbid(sbid);
        System.out.println("<====sboard=====>"+sboard);
        boolean falg2Sboard=false;
        if (sboard!=null){
            falg2Sboard=sboardService.deleteSboard(sboard.getSbid());
        }
        if (falg2Sboard){
            System.out.println("<===删除成功==>");

        }else {
            System.out.println("<====删除失败====>");
        }
        response.sendRedirect("secondBoardListServlet");

    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
